package com.cyzy;

import java.io.*;
import java.net.*;

public class App {
    public static void main(String[] args) {
        String host = "127.0.0.1"; // 如果服务端在本机
        int port = 8083;

        try (
                Socket socket = new Socket(host, port);
                BufferedReader in = new BufferedReader(new InputStreamReader(socket.getInputStream()));
                PrintWriter out = new PrintWriter(socket.getOutputStream(), true)
        ) {

            // 发送一个 '1' 给服务端
            out.println("1");
            System.out.println("已发送");
            // 读取服务端返回的数据
            String response = in.readLine();
            System.out.println("收到服务端数据: " + response);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}